<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <%
        var option = (SearchOption)ViewData["Option"];
        var searchResult = Model != null ? (List<Article>)Model : null;
    %>
    <% if (!string.IsNullOrEmpty(option.SearchText))
       { %>
    <div class="ui-widget-content ui-corner-all" style="padding: 5px;">
        <% Html.RenderPartial("QuickSearch", option); %>
    </div>
    <%}
       if (!string.IsNullOrEmpty(option.Archive))
       { %>
    <h1 style="padding-left: 10px;">
        <%:option.Archive %></h1>
    <% }
    if (!string.IsNullOrEmpty(option.TagName))
    { %>
    <h1 style="padding-left: 10px;">
        Tag:<%:option.TagName%></h1>
    <% }
         if (searchResult != null)
         {
    %>
    <ul class="ui-helper-reset" style="margin: 10px;">
        <%foreach (var article in searchResult)
          { %>
        <li>
            <h2 style="padding: 5px;"  class="ui-title">
                <a href="<%:article.GetPermaLinkUrl() %>">
                    <%:Html.Highlight(option.SearchText, article.GetGlobalizationContent().Title)%></a></h2>
            <div style="padding: 5px;">
                <%:Html.Highlight(option.SearchText, article.GetGlobalizationContent().Summary)%></div>
            <div style="margin: 5px; overflow: auto; display: block; clear: left;border-top:1px solid #cccccc;padding-top:5px;">
            <%:Html.ImageLinkList()
                 .Options(opts =>
                                          {
                                              opts.CssClass = "ui-helper-reset";
                                              opts.ItemCssStyleText = "float:left;margin-right:5px;";
                                              opts.ImageCssStyleText = "float:left;margin-right:2px;";
                                              opts.TitleCssStyleText = "float:left;padding-top:2px;";
                                          })
                .Items(items => {
                    var parent = article.GetParent();
                    var rootID = WebHost.EnablePersonalWeb ? WebSite.Open(article.UserName).DefaultCategory().ID : WebSite.Open().DefaultCategory().ID;
                    items.Add(Html.Global("publishing", "FiledUnder"), Url.Content("~/Content/Images/doc_cat.gif"));
                    items.Add( (parent.ID == rootID  || parent.Title.Equals("{site}",StringComparison.OrdinalIgnoreCase)) ? Html.Global("publishing", "Uncategorized") : parent.Title, "", parent.GetPermalinkUrl().ToString());
                    if (!string.IsNullOrEmpty(article.Categories))
                    {
                        var cats = article.GetCategories();
                        foreach (var c in cats)
                            items.Add((c.ID == rootID || c.Title.Equals("{site}", StringComparison.OrdinalIgnoreCase)) ? Html.Global("publishing", "Uncategorized") : c.Title, "", parent.GetPermalinkUrl().ToString());
                    }

                    items.Add(Html.Global(article.Posted), Url.Content("~/Content/Images/calender.gif"));

                    if (article.AllowComments)
                        items.Add(Html.Global("publishing", "GoToComments"), Url.Content("~/Content/Images/comments.gif"), "#commentlist");
                    
                    if (((WebContext.Current.Web.IsRoot) && (Html.IsAuthorize<DNA.Mvc.Areas.Publishing.Controllers.ArticleController>("Edit"))) ||
                        (WebContext.Current.User.IsWebOwner()))
                        items.Add(Html.Global("RES_EDIT"), Url.Content("~/Content/Images/edit_page.png"), Url.Action("Edit", "Article", new { website = WebContext.Current.Web.Name, id = article.ID, Area = "Publishing" }));
                   
                })
                .Render()
    %>
                <%-- Html.RenderPartial("Addition", article); --%>
            </div>
        </li>
        <%} %>
    </ul>
    <%}
       else
       {%>
    <div class="ui-state-highlight ui-corner-all" style="padding: 10px; margin: 5px;
        display: block;">
        <span style="float: left; margin-right: 0.3em;" class="ui-icon ui-icon-info"></span>
        <%:Html.Global("Publishing","NoSearchResult") %>
    </div>
    <%} %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="head" runat="server">
</asp:Content>
